﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Business.Entities;
using Business.Logic;
using System.Data;

namespace UI.Desktop
{
    public partial class CursosD : Form
    {
        public CursosD()
        {
            InitializeComponent();
        }

        private void tsbConsultar_Click(object sender, EventArgs e)
        {
            int id = ((CursoD)this.dgvCursos.SelectedRows[0].DataBoundItem).ID;
            CursosDesktop curDesk = new CursosDesktop(CursosDesktop.ModoForm.Consulta, id);
            curDesk.Text = "Consultar Curso";
            curDesk.ShowDialog();
        }

        private void CursosD_Load(object sender, EventArgs e)
        {
            this.dgvCursos.AutoGenerateColumns = false;
            this.Listar();
        }

        #region Metodos

        private void Listar()
        {
            CursoLogic curLog = new CursoLogic();
            this.dgvCursos.DataSource = null;
            this.dgvCursos.DataSource = curLog.GetAll();
        }

        #endregion

        private void btnSalir_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnActualizar_Click(object sender, EventArgs e)
        {
            this.Listar();
        }

        private void tsbNuevo_Click(object sender, EventArgs e)
        {
            CursosDesktop curDesk = new CursosDesktop(CursosDesktop.ModoForm.Alta);
            curDesk.Text = "Crear curso nuevo";
            curDesk.ShowDialog();
            this.Listar();
        }
        /*
        private void tsbEditar_Click(object sender, EventArgs e)
        {
            int id = ((CursoD)this.dgvCursos.SelectedRows[0].DataBoundItem).ID;
            CursosDesktop curDesk = new CursosDesktop(CursosDesktop.ModoForm.Modifica, id);
            curDesk.Text = "Editar Curso";
            curDesk.ShowDialog();
        }
        */
        private void tsbEliminar_Click(object sender, EventArgs e)
        {
            int id = ((CursoD)this.dgvCursos.SelectedRows[0].DataBoundItem).ID;
            CursosDesktop curDesk = new CursosDesktop(CursosDesktop.ModoForm.Baja, id);
            curDesk.Text = "Eliminar Curso";
            curDesk.ShowDialog();
        }
    }
}
